
// 1. 要有组件

import { createWebHashHistory, createRouter } from 'vue-router';

// 2. 定义一些路由（路径与组件之间的映射）
const routes = [
    // 后台管理员
    {name: 'login',path: '/login', component: ()=>import('@/view/Login.vue')},
    {name: 'index', path: '/', component: ()=>import('@/view/Index.vue'), children: [
            {name: 'charts',path: '/charts', component: ()=>import('@/view/Charts.vue')},
            {name: 'user',path: '/user', component: ()=>import('@/view/User.vue')},
            {name: 'drug',path: '/drug', component: ()=>import('@/view/Drug.vue')},
            {name: 'messages',path: '/messages', component: ()=>import('@/view/Message.vue')},
            {name: 'category',path: '/category', component: ()=>import('@/view/Category.vue')},
            {name: 'warehouse',path: '/warehouse', component: ()=>import('@/view/Warehouse.vue')},
            {name: 'orders',path: '/orders', component: ()=>import('@/view/Orders.vue')},
            {name: 'customer',path: '/customer', component: ()=>import('@/view/Customer.vue')},
            {name: 'supplier',path: '/supplier', component: ()=>import('@/view/Supplier.vue')},
            {name: 'purchase',path: '/purchase', component: ()=>import('@/view/Purchase.vue')},
        ]},
];

// 3. 创建路由
const router = createRouter({
    history: createWebHashHistory(),    // 历史记录
    routes: routes,
});

// 路由是否已经加载
router.load = false;

// 4. 暴露
export default router